package cn.bluech.lib.ui.widget.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.LayoutRes;
import androidx.annotation.StringRes;

import cn.bluech.lib.R;


/**
 * Description:
 * Create by Codeant on 2018/10/23.
 */
public class LoadingDialog extends BaseDialog {
    private TextView msgTv;

    public LoadingDialog(Context context) {
        this(context,R.layout.dlg_loading);
        msgTv = findViewById(R.id.msgTv);

    }

    public LoadingDialog(Context context, @LayoutRes int lyId){
        this(context,View.inflate(context,lyId,null));
    }

    public LoadingDialog(Context context, View view) {
        super(context,view);
//        view.setMinimumHeight(DispUtils.dp2px(context,50));
        // 禁用取消(需要手动调用dismiss()才能关闭弹窗)
        setCancelable(false);
    }


    @Override
    public LoadingDialog show(CharSequence msg) {
        super.show();
        if(null!=msgTv)
            msgTv.setText(msg);

        return this;
    }

    @Override
    public LoadingDialog show(@StringRes int msgId) {
        return show(ctx.getText(msgId));
    }
}
